//
//  LinkingCardTipsView.swift
//  iPhone
//
//  Created by Toj on 11/9/22.
//

import UIKit

class LinkingCardTipsView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupSubviews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        setupLayoutSubviews()
    }
    
    private lazy var imageView = UIImageView()
    
    private lazy var titleLabel: UILabel = {
        let view = UILabel()
        view.text = "Your smart card has been successfully bound to three OTT accounts. Please call customer service to unbind or log in to the bound OTT account to unbind"
        view.numberOfLines = 0
        view.textAlignment = .center
        view.textColor = "#666666".to_color
        view.font = UIFont.systemFont(ofSize: 14.f_scale)
        return view
    }()
    
    private let okButtonHeight = 32.ui_scale
    private(set) lazy var okButton: UIButton = {
        let view = UIButton()
        view.backgroundColor = "#E8CD8C".to_color
        view.setTitle("OK", for: .normal)
        view.setTitleColor("#775E33".to_color, for: .normal)
        view.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14.f_scale)
        view.cm_cornerRadius = okButtonHeight * 0.5
        return view
    }()
    
    deinit {
        // print("-->toj: LinkingCardTipsView " + #function)
    }
}

extension LinkingCardTipsView {
    
    private func setupSubviews() {
        
        addSubview(titleLabel)
        addSubview(okButton)
    }
    
    private func setupLayoutSubviews() {
        
        okButton.snp.makeConstraints { make in
            make.height.equalTo(okButtonHeight)
            make.bottom.equalTo(snp.bottom).offset(-30)
            make.left.right.equalTo(self).inset(16.ui_scale)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(self)
            make.bottom.equalTo(okButton.snp.top)
            make.left.right.equalTo(self).inset(16.ui_scale)
        }
    }
}
